﻿using Microsoft.AspNetCore.Builder;
using System;
using System.Collections.Generic;
using System.Text;
using Nancy.Owin;
using Microsoft.Extensions.Configuration;
using Microsoft.AspNetCore.Hosting;

namespace dotnetcorenancy
{
	public class Startup
	{
		private readonly IConfiguration config;

		public Startup(IHostingEnvironment env)
		{
			var builder = new ConfigurationBuilder()
							  .AddJsonFile("appsettings.json")
							  .SetBasePath(env.ContentRootPath);

			config = builder.Build();
		}

		public void Configure(IApplicationBuilder app)
		{
			var appConfig = new AppConfiguration();
			ConfigurationBinder.Bind(config, appConfig);

			app.UseOwin(x => x.UseNancy(opt => opt.Bootstrapper = new DemoBootstrapper(appConfig)));
		}
	}
}
